You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds a standalone LDAP authentication sidecar for Dragonfly using search-and-bind authentication. Group support and CRD integration remain deferred to later PRs.
Changes:
Adds HTTP validation and health endpoints with graceful shutdown.
Adds environment-based LDAP configuration, TLS support, and search-and-bind authentication.
Moves the operator entry point and tests into cmd/operator, updates build paths, and adds LDAP dependencies.
File
Description
Makefile
Updates operator build and run paths.
go.sum
Adds LDAP dependency checksums.
go.mod
Declares LDAP client dependencies.
Dockerfile
Builds the relocated operator entry point.
cmd/operator/main.go
Relocates the operator entry point.
cmd/operator/main_test.go
Relocates operator tests.
cmd/auth-sidecar/search.go
Implements LDAP user lookup and credential binding.
cmd/auth-sidecar/main.go
Adds HTTP endpoints and server lifecycle handling.
LDAP operations can hang indefinitely after connection
cmd/auth-sidecar/auth.go:45
The dialer timeout only bounds connection establishment, and the search time limit does not bound client-side LDAP I/O; go-ldap's inspected default branch initializes its request timeout to zero (not the pinned v3.4.15). A directory that accepts TCP but stops replying can therefore retain handlers and connections indefinitely, since the initial context check and HTTP write timeout do not interrupt LDAP operations. Install a client-side LDAP timeout before StartTLS/binding and propagate request cancellation so it closes the connection.
Reject incomplete client certificate and key configuration
cmd/auth-sidecar/auth.go:65
If only LDAP_TLS_CERT or LDAP_TLS_KEY is configured, this condition silently skips the client certificate, and startup validation still succeeds because it calls this same function. A partially configured mTLS identity therefore produces connections without the intended certificate and fails authentication only at request time. Reject an unmatched certificate/key pair during configuration loading.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
LDAP searches returning zero or multiple users are treated as successful authentication, allowing nonexistent usernames with any nonempty password to bypass authentication.
Require exactly one LDAP user match before authenticating
cmd/auth-sidecar/search.go:58
A zero- or multiple-entry search returns a nil error, which handler treats as successful authentication (main.go:98–99). A nonexistent username with any nonempty password therefore receives {"valid":true} without a user bind. Return an authentication failure when the search does not identify exactly one user, and add regression cases for zero and multiple matches.
Apply client-side deadlines and cancellation to LDAP operations
cmd/auth-sidecar/auth.go:45
An LDAP peer that stops replying during StartTLS or either bind can leave handlers and connections stuck indefinitely because neither HTTP WriteTimeout nor the search's server-side time limit interrupts that work. No client-side LDAP timeout is configured here; the inspected go-ldap default-branch source initializes it to zero. Apply client-side deadlines covering LDAP operations and the TLS handshake, and thread the request context into connect so cancellation closes the connection.
Supplying only LDAP_TLS_CERT or only LDAP_TLS_KEY silently skips loading client credentials. Since cfg.validate() relies on this function, that incomplete configuration passes startup validation, but authentication against a directory requiring mutual TLS then fails on every request. Reject configurations where exactly one half of the certificate/key pair is present instead of silently ignoring it.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The sidecar cannot build because its config literal uses promoted fields, and malformed StartTLS settings can silently disable encryption and expose LDAP credentials over plaintext.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add auth sidecar server that supports search+bind LDAP operation. Group support, CRD integration will be done in the next PRs.